/*****************
Class Renderer

*Initialize with a valid device
*Either use DrawScene(Node*) to draw all the geometry that belongs to the given node or;
		use Draw(Geometry*) to draw the given Geometry.
******************/

#ifndef GRAPHICS__RENDERER_H_
#define GRAPHICS__RENDERER_H_

#include "Vertex.h"
#include "framework.h"

using namespace poly;

namespace graphics
{
using namespace poly;

class Node;
class Geometry;

class Renderer
{
public:
	Renderer(){};
	~Renderer();

	/**
	 * Has to be called prior to any other function call.
	 */
	void Initialize(D3DDevice);

	/**
	 * Draws all the Geometry that belongs to that node and its subnodes.
	 */
	void DrawScene(Node*);
	/**
	 * Draws Geometry.
	 */
	void Draw(Geometry*);

	/**
	 * Internal call. Updates the render states from the last traversal of the graph.
	 */
	void UpdateRenderStates();

	/**
	 * Internal call. Final draw function.
	 */
	void DrawPrimitive();
private:
	/**
	 * Current device
	 */
	D3DDevice m_Device;

	/**
	 * Copies of the current Geometry info (changes to the Geometry with each Draw(Geometry*) call
	 */
	Geometry*				m_Geometry;

	/**
	 * Current vertex buffer.
	 */
	IDirect3DVertexBuffer9* m_VertexBuffer;

	/**
	 * Vertex type.
	 */
	int						m_VertexType;

};

}/* namespace graphics */
#endif /*GRAPHICS__RENDERER_H_*/